package androcr.client.mobile.display.servicechooser;

import androcr.client.mobile.R;
import androcr.client.mobile.services.servicechooser.IServiceChooserPresenter;
import androcr.client.mobile.services.servicechooser.ServiceChooserPresenter;
import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnKeyListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class ServiceChooserActivity extends Activity implements IServiceChooserActivity{
	private static final String TAG = "ServiceChooserActivity";
	
	private IServiceChooserPresenter scPresenter;
	
	private Button buttonTts;
	private Button buttonTranslate;
	private Button buttonSearch;
	private EditText editTextTextToRead;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
		setContentView(R.layout.service_chooser);
		
		scPresenter = new ServiceChooserPresenter(this);
		
		buttonTts = (Button) findViewById(androcr.client.mobile.R.id.buttonTextToSpeech);
		buttonTts.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
            	scPresenter.updateString();
            	scPresenter.startTextToSpeechService(v.getContext());
            }
        });
		
		buttonTranslate = (Button) findViewById(androcr.client.mobile.R.id.buttonTranslate);
		buttonTranslate.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
            	scPresenter.updateString();
            	scPresenter.startTranslatorService(v.getContext());
            }
        });
		
		buttonSearch = (Button) findViewById(androcr.client.mobile.R.id.buttonSearch);
		buttonSearch.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
            	scPresenter.updateString();
            	scPresenter.startWebSearchService(getEditedText());
            }
        });
		
        editTextTextToRead = (EditText) findViewById(R.id.editTextRecognizedText);
		
	}
	
	@Override
    public void onDestroy() {
        super.onDestroy();
    }
    
    @Override
    public void onPause(){
    	super.onPause();
    }
    
    @Override
    public void onResume(){
    	super.onResume();
    }


	public void setRecognizedText(CharSequence charSequence) {
		editTextTextToRead.setText(charSequence);
	}

	@Override
	public String getEditedText() {
		return editTextTextToRead.getText().toString();
	}
}
